function selectInit(select,text,textsArr,callback){
    $('#'+select).multiselect({
        noneSelectedText: "=="+text+"==",
        checkAllText: "全选",
        uncheckAllText: '全不选',
        selectedText: '# 个被选中',
        checkAll:function(ui){
            textsArr=[];
            for(var f=0; f< ui.target.length;f++){
                textsArr.push(ui.target[f].value)
            }
            if(callback!=undefined){
                callback(textsArr)
            }
          // console.log(ui.target[0].value);
        },
        uncheckAll:function(ui){
            textsArr=[];
            if(callback!=undefined){
                callback(textsArr)
            }
            /*for(var f in ui.target){
                textsArr.push(ui.target[f].value)
            }*/
            // console.log(ui.target[0].value);
        },
        click:function(event,ui){
            var oHeight = $("#select_ms").height();
            $("#select_ms").css({
                "overflow": "hidden", "white-space": "nowrap", "text-overflow": "ellipsis"
            })
            if(ui.checked){
                textsArr.push(ui.value);
            }else{
                var index;
                if(!textsArr.indexOf){
                    textsArr.indexOf = function(elt /*, from*/){
                        var len = this.length >>> 0;
                        var from = Number(arguments[1]) || 0;
                        from = (from < 0)
                            ? Math.ceil(from)
                            : Math.floor(from);
                        if (from < 0)
                            from += len;
                        for (; from < len; from++)
                        {
                            if (from in this &&
                                this[from] === elt)
                                return from;
                        }
                        return -1;
                    };
                    index=textsArr.indexOf(ui.value);
                }else{
                    index= textsArr.indexOf(ui.value);
                }

                if(index>(-1)){
                    textsArr.splice(index, 1);
                }

            }
            return textsArr;
        },
        selectedList:1
    })
}
function getSelectData(datas,select){
    $("#"+select).empty();
    for(var dat=0;dat<datas.length;dat++){
        var showName=datas[dat].showName!=undefined?datas[dat].showName:datas[dat];
        var researchName=datas[dat].researchName!=undefined?datas[dat].researchName:datas[dat];
        var option = "<option value='"+researchName+"'>"+showName+"</option>";
        $("#"+select).append(option);
    }
    $("#"+select).multiselect('refresh');
}

/*
function getAllselectVal(callback){
    return $(".ui-multiselect-all").click(function(){
        var self=this;
        setTimeout(function(){
            var arr=[];
            var oInput=$(self).parents(".ui-widget-content").find(".ui-multiselect-checkboxes li input");
            for(var i=0;i<oInput.length;i++){
                if($(oInput).eq(i).attr("aria-selected")=="true"){
                    arr.push($(oInput).eq(i).val())
                }
            }
            if(arr.length>0){
                callback(arr)
            }
           // return arr;
            clearTimeout();
        },500)

    })
}

function delectAllselectVal(callback){
    $(".ui-multiselect-all").click(function(){
        //getValue(arr);
        callback([])
    })

}*/